package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.MarketComment;
import com.cskaoyan.bean.MarketOrder;
import com.cskaoyan.bean.address.IdPo;
import com.cskaoyan.bean.order.bo.CreateOrderBo;
import com.cskaoyan.bean.order.vo.*;
import com.cskaoyan.service.order.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * 
 * 创建日期: 2022/05/07 19:43
 * @author wangyonghong
 */
@RestController
@RequestMapping("wx/order")
public class InfoOrderController {
    @Autowired
   OrderService orderService;
    @PostMapping ("submit")
    public BaseRespVo delete(@RequestBody CreateOrderBo createOrderBo) {
        SubmitVo submitVo  =orderService.submit(createOrderBo);
        return  BaseRespVo.ok(submitVo);
    }
    @GetMapping("list")
    public BaseRespVo list( PaginationPo paginationPo) {
        InfoOrderVo infoOrderVo=orderService.list(paginationPo);
        return  BaseRespVo.ok(infoOrderVo);
    }

    @GetMapping("detail")
    public BaseRespVo detail( Integer orderId ) {
        OrderGoodsDetailVo orderGoodsDetailVo=orderService.detail(orderId);
        return  BaseRespVo.ok(orderGoodsDetailVo);
    }




    @PostMapping("prepay")
    public BaseRespVo prepay(@RequestBody IdPo orderId ) {
//        orderService.prepay(orderId);
        return  BaseRespVo.ok("不能付款");
    }

    @PostMapping("cancel")
    public BaseRespVo cancel(@RequestBody IdPo orderId ) {
        orderService.cancel(orderId);
        return  BaseRespVo.ok("成功");
    }
    @PostMapping("delete")
    public BaseRespVo delete(@RequestBody IdPo orderId ) {
        orderService.delete(orderId);
        return  BaseRespVo.ok("成功");
    }
    @PostMapping("refund")
    public BaseRespVo refund(@RequestBody IdPo orderId ) {
        orderService.refund(orderId);
        return  BaseRespVo.ok("成功");
    }
    @PostMapping("confirm")
    public BaseRespVo confirm(@RequestBody IdPo orderId ) {
        orderService.confirm(orderId);
        return  BaseRespVo.ok("成功");
    }
    @PostMapping("comment")
    public BaseRespVo comment(@RequestBody MarketComment marketComment ) {
        orderService.comment(marketComment);
        return  BaseRespVo.ok("成功");
    }

    @GetMapping("goods")
    public BaseRespVo goods(Integer orderId,Integer goodsId) {
        orderService.goods(orderId,goodsId);
        return  BaseRespVo.ok("成功");
    }
}
